package tedu.study.Day05_2;

import java.util.Arrays;
import java.util.Random;

public class ArrayDemo {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arr = new int[10];
        System.out.println("排序前：");
        for(int i=0;i<arr.length;i++){
            arr[i] = random.nextInt(100);
            System.out.print(arr[i]+"\t");
        }
        System.out.println();

        //排序
        Arrays.sort(arr);

        //排序后
        System.out.println("排序后：");
        for(int i=0;i<arr.length;i++){
            System.out.print(arr[i]+"\t");
        }
        System.out.println();

        System.out.println("倒着展示：");
        for(int i=arr.length-1;i>=0;i--){
            System.out.print(arr[i]+"\t");
        }
        System.out.println();

        System.out.println("第一个元素是："+arr[0]);


        /*int[] arr = new int[10];
        for(int i=0;i<arr.length;i++){
            arr[i] = (int)(Math.random()*100);
            System.out.println(arr[i]);
        }*/


        /*
        int[] a = new int[3];
        double[] b = new double[5];
        boolean[] c = new boolean[10];

        int[] arr1 = new int[5];
        int[] arr2 = {4,6,8};
        int[] arr3 = new int[]{10,11,12};
        int[] arr4;
        arr4 = new int[6];
        //arr4 = {1,2,3};
        arr4 = new int[]{11,12,23};

        int[] a1 = new int[3];
        double[] b2 = new double[5];
        boolean[] c3 = new boolean[10];

        int[] brr1 = new int[5];
        int[] brr2 = {7,8,9};
        int[] brr3 = new int[]{1,5,7};
        int[] brr4;
        brr4 = new int[10];
        //brr4 = {10,6,9};
        brr4 = new int[]{8,94,2};


        int[] arr = new int[3];
        System.out.println("数组的长度是："+arr.length);
        System.out.println(arr[0]);
        arr[0] = 100;
        arr[1] = 200;
        arr[2] = 300;

        //arr[5] = 400;
        System.out.println(arr[arr.length-1]);
*/
    }
}
